﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;
using TrialManagmentTool.Models;

namespace TrialManagmentTool.Controllers.API
{
    public class TrialController : ApiController
    {
        public List<TrialViewModel> GetAllWork()
        {
            string json = "";
            TrialViewModel model = new TrialViewModel();
            model.City = "上海";
            model.Crop = "水稻";
            model.Operation = "0?123";
            model.Procuct = "杀虫剂";
            model.Promoter = "ss";
            List<TrialViewModel> result = new List<TrialViewModel>();
            result.Add(model);
            //System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(result.GetType());

            //using (MemoryStream ms = new MemoryStream())
            //{
            //    serializer.WriteObject(ms, result);
            //    json = Encoding.UTF8.GetString(ms.ToArray());
            //}
            //json = "{'page':'" + 1 + "','total':'" + 0 + "','records':'" + 1 + "','rows':'" + json + "'}";

            return result;
        }
    }
}
